package com.mail.anteater.dao;

import java.util.ArrayList;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.mail.anteater.hibernate.HibernateUtil;
import com.mail.anteater.hibernate.mapping.User;

public class UserDAO {

	public static User getUser(String userId, boolean isNestedOperation){
		DetachedCriteria cri = DetachedCriteria.forClass(User.class);
		cri.add(Restrictions.eq("userId", userId));
		
		ArrayList<Object> list = HibernateUtil.list(cri, isNestedOperation);
		if(list != null){
			if(list.size() <= 0){
				return null;
			}else{
				User user = (User) list.get(0);	
				return user;
			}
		}else{
			return null;
		}
	}
}
